package com.canbot.u05.activity.shoppingGuide.codeMarketing;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;

import com.canbot.u05.activity.BaseActivityNoTitle;

public class BaseCodeFinishActivity extends BaseActivityNoTitle {

        public static final String CODE_FINISH_ACTION = "code_marketing_finish_action";

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, new IntentFilter(CODE_FINISH_ACTION));
        }

        private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                        finish();
                }
        };

        @Override
        protected void onDestroy() {
                LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver);
                super.onDestroy();

        }

        protected void sendFinishCodeBroadcast() {
                LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(CODE_FINISH_ACTION));
        }
}
